////
//
/// \file ./include/inc/parser/block_entry_node.hpp
//
//  Copyright 2007, 2008 Chandler Carruth
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations
//  under the License.
//
////

#ifndef inc_parser_block_entry_node_header
#define inc_parser_block_entry_node_header

#include <string>

#include <boost/scoped_ptr.hpp>

#include <inc/parser/parse_tree_node.hpp>

namespace inc {
namespace parser {

class StatementNode;
class IfStatementNode;
class LocalDeclNode;

/// \brief  Block entry parse node
/// \author Chandler Carruth
/// \date   2007.08.12
///
/// This is the block entry parse node. Conventional terminology often refers 
/// to this as a "statement" however, that is reserved for a different 
/// component of the INC grammar. The concept is that "statement"s are 
/// actions, or changes in the state of the program. The block level can hold 
/// many syntactic constructs that do not fit that definition. Among these are 
/// flow control, and variable declarations.
/// 
/// TODO(chandlerc): Loop actions, which are to an extent a component of flow
/// control, are modeled as statements currently, but would be better modeled
/// here, as they change the flow control constructs, but do not technically
/// affect the state of the program. However this runs the risk of nested
/// non-block conditionals, so that would need to be resolved.

class BlockEntryNode : public ParseTreeNode
{
public:
  BlockEntryNode();
  virtual ~BlockEntryNode();

  virtual bool parse( const iterator& first,
                      const iterator& last,
                      iterator& last_parsed );

  virtual StatementNode* get_statement() const;
  virtual bool is_statement() const { return get_statement() != NULL; }
  virtual IfStatementNode* get_if_statement() const;
  virtual bool is_if_statement() const { return get_if_statement() != NULL; }
  virtual LocalDeclNode* get_local_decl() const;
  virtual bool is_local_decl() const { return get_local_decl() != NULL; }

private:
  boost::scoped_ptr<ParseTreeNode> node;
};

} //  end parser namespace
} //  end inc namespace
#endif  //  inc_parser_block_entry_node_header
